﻿<Window 
    x:Class="Templates.MainView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    WindowStartupLocation="CenterScreen" WindowState="Maximized"
    Title="Templates" Height="600" Width="800">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="250" />
            <ColumnDefinition />
        </Grid.ColumnDefinitions>
        
        <Menu Grid.ColumnSpan="2">
            <MenuItem Header="_File">
                <MenuItem Header="_Open" Command="{Binding OpenFile}" />
                <MenuItem Header="_Save" Command="{Binding SaveFile}" />
                <MenuItem Header="E_xit" Command="{Binding Close}" />
            </MenuItem>
            <MenuItem Header="_Template">
                <MenuItem Header="_Open Template" Command="{Binding OpenTemplate}" />
                <MenuItem Header="_Import Template" Command="{Binding ImportTemplate}" />
                <MenuItem Header="_Save Template" Command="{Binding SaveTemplate}" />
            </MenuItem>
            <MenuItem Header="_Help">
                <MenuItem Header="_About" Command="{Binding About}" />
            </MenuItem>
        </Menu>
        
        <Grid Grid.Row="1">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="*" />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition />
                <ColumnDefinition />
            </Grid.ColumnDefinitions>
            
            <TextBlock Margin="5,0" HorizontalAlignment="Right" VerticalAlignment="Center">Start Character</TextBlock>
            <TextBlock Grid.Row="1" Margin="5,0" HorizontalAlignment="Right" VerticalAlignment="Center">End Character</TextBlock>
            <TextBlock Grid.Row="2" Margin="5,0" HorizontalAlignment="Right" VerticalAlignment="Center">Ignore Case</TextBlock>
            
            <TextBox Grid.Column="1" Margin="5" Text="{Binding StartCharacter, UpdateSourceTrigger=PropertyChanged}" />
            <TextBox Grid.Row="1" Margin="5" Grid.Column="1" Text="{Binding StartCharacter, UpdateSourceTrigger=PropertyChanged}" />
            <CheckBox Grid.Row="2" Margin="5" Grid.Column="1" IsChecked="{Binding IgnoreCase}" />

            <StackPanel Grid.Row="3" Grid.ColumnSpan="2" HorizontalAlignment="Center" Orientation="Horizontal">
                <TextBlock Margin="5">- Variables -</TextBlock>
                <Button Grid.Column="2" Command="{Binding AddVariable}" Margin="5" Height="20" Width="20">+</Button>
            </StackPanel>
            
            <ItemsControl Grid.Row="4" Grid.ColumnSpan="2" ItemsSource="{Binding Variables}">
                <ItemsControl.ItemTemplate>
                    <DataTemplate>
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition />
                                <ColumnDefinition />
                                <ColumnDefinition Width="Auto" />
                            </Grid.ColumnDefinitions>

                            <TextBox Grid.Column="0" Margin="5" Text="{Binding Name, UpdateSourceTrigger=PropertyChanged}" />
                            <TextBox Grid.Column="1" Margin="5" Text="{Binding Value, UpdateSourceTrigger=PropertyChanged}" />
                            <Button Grid.Column="2" Command="{Binding Delete}" Margin="5" Height="20" Width="20">X</Button>
                        </Grid>
                    </DataTemplate>
                </ItemsControl.ItemTemplate>
            </ItemsControl>
            
        </Grid>
        
        <TextBox Grid.Row="1" Grid.Column="1" AcceptsReturn="True" AcceptsTab="True" Text="{Binding Body, UpdateSourceTrigger=PropertyChanged}" />
    </Grid>
</Window>
